package biz.innovasoft.nodb.transaction;

import java.util.Date;

import org.prevayler.Transaction;

import biz.innovasoft.nodb.impl.GenericRepository;

public class DeleteTransaction implements Transaction {

	private static final long serialVersionUID = 1L;
	
	private final Object data;
	
	public DeleteTransaction (Object data) {
		this.data = data;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public void executeOn(Object prevalentSystem, Date time) {
		GenericRepository repository = (GenericRepository)prevalentSystem;
		if (data instanceof Class) {
			repository.delete((Class<?>)data);
		} else if (data instanceof Long) {
			repository.delete ((Long)data);
		} else if (data instanceof Long[]) {
			repository.delete ((Long[])data);
		}
	}

}
